package com.tao.demo.domain.vo;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.tao.demo.domain.entity.WaterQuality;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.Map;

/**
 * @projectName: rivers
 * @package: com.tao.demo.domain.vo
 * @className: CategoryVO
 * @author: DemoTao
 * @description: TODO
 * @date: 2024/4/26 21:51
 * @version: 1.0
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class RelevanceVO implements Serializable {
  @Serial
  private static final long serialVersionUID = 1L;
  
  private double dissolvedOxygen;
  private double conductivity;
  
  public static RelevanceVO fromEntity(WaterQuality waterQuality) {
    if (waterQuality == null) {
      return null;
    }
    RelevanceVO vo = new RelevanceVO();
    BeanUtil.copyProperties(waterQuality, vo);
    return vo;
  }
  
  public static RelevanceVO fromEntity(Map<String, Object> maps) {
    if (maps == null) {
      return null;
    }
    return BeanUtil.mapToBean(maps, RelevanceVO.class, false, new CopyOptions());
  }
  
}
